package com.codebuffer.nowcoder;

import java.util.ArrayList;
import java.util.List;

public class FindContinuousSequence {
    public static ArrayList<ArrayList<Integer>> FindContinuousSequence(int sum) {

        ArrayList<ArrayList<Integer>> result = new ArrayList<>();
        for (int i = 1; i <= sum/2; i++) {
            int sumN = 0;
            ArrayList<Integer> list = new ArrayList<>();
            int n = i;
            while (sumN<sum){
                sumN += n;
                list.add(n++);
            }
            if(sum==sumN){
                result.add(list);
            }
        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println(FindContinuousSequence(9).toArray());
    }
}
